package cn.usian.controller;

import cn.usian.common.ResultEnum;
import cn.usian.dto.UserDto;
import cn.usian.common.Results;
import cn.usian.pojo.User;
import cn.usian.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("auth/login")
    public Results login(@RequestBody User user){
        return userService.login(user);
    }

    @RequestMapping("auth/loginCode")
    public Results LoginCode(String phone, Integer status){
       return userService.LoginCode(phone,status);
    }

    @RequestMapping("auth/toLoginCode")
    public Results toLoginCode(@RequestBody UserDto userDto){
        return userService.toLoginCode(userDto);
    }

    @RequestMapping("auth/toRegister")
    public Results toRegister(@RequestBody UserDto userDto){
        return userService.toRegister(userDto);
    }

    @RequestMapping("auth/toUpdatPws")
    public Results toUpdatPws(@RequestBody UserDto userDto){
        return userService.toUpdatPws(userDto);
    }

    @RequestMapping("findUserType")
    public Results findUserType(){
        return userService.findUserType();
    }

    @RequestMapping("auth/findUserName")
    public Long findUserName(String username){
        return userService.findUserName(username);
    }
}
